﻿using Microsoft.EntityFrameworkCore;
using ProjectCore.Domain.DomainService;
using ProjectCore.Domain.Model.Entity;
using ProjectCore.Domain.Repository.Interfaces;
using ProjectCore.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProjectCore.Infrastructure.DomainService
{
    public class UserDomainService : IUserDomainService
    {
        private readonly IBaseRepository<Users> baseRepository;
        private readonly MyContext myContext;
        public UserDomainService(IBaseRepository<Users> _baseRepository, MyContext _myContext)
        {
            baseRepository = _baseRepository;
            myContext = _myContext;
        }

        //删除
        public async Task<int> DelUserI(int Id)
        {
            try
            {
                Users users = myContext.Users.Where(x => x.UserID.Equals(Id)).FirstOrDefault();
                users.IsDeleted = true;
                return await myContext.SaveChangesAsync();
            }
            catch (Exception) { throw; }
        }
    }
}